package com.power.util;

import jakarta.servlet.http.HttpServletResponse;

import java.io.PrintWriter;

/**
 * @Author 海晨忆
 * @Des ResponseUtils工具类
 * @Date 2025/8/11 16:50
 */
public class ResponseUtils {
    public static void write(HttpServletResponse response, String result) {
        response.setContentType("application/json;charset=utf-8");
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
            writer.write(result);
            writer.flush();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (writer != null) {
                writer.close();
            }
        }
    }
}
